package com.zzb.weikeautosign;

/**
 * 工具类
 * Created by zzb on 15/12/30.
 */
public class Misc {
    public static boolean isZero(Integer i){
        return i== null || i.equals(0);
    }
    public static boolean isZero(Float f){
        return f == null || f.equals(0f);
    }
    public static boolean isZero(Double d){
        return d == null || d.equals(0d);
    }
    public static boolean isNotZero(Integer i){
        return !isZero(i);
    }
    public static boolean isNotZero(Float f){
        return ! isZero(f);
    }
    public static boolean isNotZero(Double d){
        return ! isZero(d);
    }
    public static boolean isTrue(Boolean b){return null!=b&&b;}
    public static boolean isFalse(Boolean b){return !isTrue(b);}
    public static int toPrimitive(Integer value ,int defaultValue){return value==null?defaultValue:value;}
    public static float toPrimitive(Float value ,float defaultValue){return value==null?defaultValue:value;}
    public static double toPrimitive(Double value ,double defaultValue){return value==null?defaultValue:value;}
    public static char toPrimitive(Character value ,char defaultValue){return value==null?defaultValue:value;}
    public static boolean toPrimitive(Boolean value ,boolean defaultValue){return value==null?defaultValue:value;}
    public static short toPrimitive(Short value ,short defaultValue){return value==null?defaultValue:value;}
}
